<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of RoleAuthModel
 *
 * @author wangnaixin
 */
namespace Admin\Model;
use Think\Model;
class RoleAuthModel extends Model {
    //put your code here
    
    protected $tableName = 'role_auth';
    
    public function getAuthListByRoleId($roleId){
        return $this->where("role_id = ".$roleId)->field("auth_id")->select();
    }
    
    public function delByRoleId($roleId){
        return $this->where("role_id = ".$roleId)->delete();
    }
    
    public function setRoleIdAuths($roleId,$auths){
        foreach ($auths as $v){
            $this->data(array(
                'role_id'=>$roleId,
                'auth_id'=>$v
            ))->add();
        }
        return true;
    }
}
